#ifndef __RESOURCE_H__
#define __RESOURCE_H__

#include "../Header.h"

typedef struct _Vertex
{
	Vector3 m_Pos;
	Vector2 m_UV;
	Vector3 m_Normal;
	Vector3 m_BiNormal;
	Vector3 m_Tangent;
	Vector4 m_Color;
}Vertex;

class Resource
{
protected:
	__int32_ m_ID;
	__bool_ m_IsLoaded;
	__bool_ m_IsDelUsed;
public:
	Resource();
	~Resource();
};

template <class ResourceType>
class ResourceEx
{
private:
	char *m_Name;
	char *m_Path;
	char *m_FullFileName;
	__uint32_ m_RefCount;
public:
	ResourceEx(char* name, char* path)
	{
		//Store file name
		if (name != 0)
		{
			m_Name = new char[strlen(name) + 1];
			memcpy(m_Name, name, (strlen(name) + 1) * sizeof(char));
		}

		//Store file path
		if (path != 0)
		{
			m_Path = new char[strlen(path) + 1];
			memcpy(m_Path, path, (strlen(path) + 1) * sizeof(char));
		}

		//Store full file direc
		if (m_Name != 0 && m_Path != 0)
		{
			char* basePath = BASE_PATH;
			m_FullFileName = new char[strlen(basePath) + strlen(m_Path) + strlen(m_Name) + 1];
			sprintf(m_FullFileName, "%s%s%s", basePath, m_Path, m_Name);
		}

		//Define reference count
		m_RefCount = 0;
	}

	~ResourceEx()
	{
		SAFE_DELETE_ARRAY(m_Name);
		SAFE_DELETE_ARRAY(m_Path);
		SAFE_DELETE_ARRAY(m_FullFileName);
	}

	char *GetName() { return m_Name; }
	char *GetPath() { return m_Path; }
	char *GetFullFileName() { return m_FullFileName; }
	void IncRef() { m_RefCount++; }
	void DecRef() { m_RefCount--; }
	__uint32_ GetRefCount() { return m_RefCount; }
};

#endif